package com.ruibang.glass.quality.controller.data;

import com.ruibang.glass.quality.domain.req.EveryHourArchiveDefectReq;
import com.ruibang.glass.quality.entity.EveryHourArchiveDefect;
import com.ruibang.glass.quality.service.EveryHourArchiveDefectService;
import com.teaming.cloud.framework2.common.model.ResultBody;
import com.teaming.cloud.framework2.common.pojo.PageRequest;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;


/**
 * <p>
 * 每小时归档缺陷统计信息 前端控制器
 * </p>
 *
 * @author wujie
 * @since 2023-12-13
 */
@RestController
@RequestMapping("/api/everyHour/archive/defect")
@Api(value="每小时归档缺陷统计信息",tags={"每小时归档缺陷统计信息操作接口"})
public class EveryHourArchiveDefectController {

    @Autowired
    private EveryHourArchiveDefectService everyhourArchiveDefectService;

    /**
    * 通过id查询
    */
    @GetMapping("/getById/{id}")
    @ApiOperation(value="获取每小时归档缺陷统计信息",notes="获取每小时归档缺陷统计信息")
    public ResultBody getById(@PathVariable(value = "id") Integer id){
        return ResultBody.success(everyhourArchiveDefectService.getById(id));
    }

    /**
    * 新增
    */
    @PostMapping("/save")
    @ApiOperation(value="新增每小时归档缺陷统计信息",notes="新增每小时归档缺陷统计信息")
    public ResultBody save(@RequestBody EveryHourArchiveDefect everyhourArchiveDefect){
        everyhourArchiveDefectService.save(everyhourArchiveDefect);
        return ResultBody.success();
    }

    @GetMapping("/deleteById/{id}")
    @ApiOperation(value="通过ID删除每小时归档缺陷统计信息",notes="通过ID删除每小时归档缺陷统计信息")
    public ResultBody delete(@PathVariable(value = "id") String ids){
        String[] idsStrs = ids.split(",");
        for (String id:idsStrs){
            everyhourArchiveDefectService.removeById(Integer.parseInt(id));
        }
        return ResultBody.success();
    }

    @PostMapping("/update")
    @ApiOperation(value="修改每小时归档缺陷统计信息",notes="修改每小时归档缺陷统计信息")
    public ResultBody updateById(@RequestBody EveryHourArchiveDefect everyhourArchiveDefect){
        everyhourArchiveDefectService.updateById(everyhourArchiveDefect);
        return ResultBody.success();
    }



    @PostMapping("/list")
    @ApiOperation(value="非分页列表查询每小时归档缺陷统计信息",notes="非分页列表查询每小时归档缺陷统计信息")
    public ResultBody list(@RequestBody EveryHourArchiveDefectReq everyHourArchiveDefect ){
        return ResultBody.success(everyhourArchiveDefectService.queryEveryHourArchiveDefects(everyHourArchiveDefect));
    }

    @PostMapping("/page")
    @ApiOperation(value="分页列表查询每小时归档缺陷统计信息",notes="分页列表查询每小时归档缺陷统计信息")
    public ResultBody page(@RequestBody PageRequest<EveryHourArchiveDefectReq> pageParam){
        return ResultBody.success(everyhourArchiveDefectService.queryPage(pageParam));
    }

}
